import { getGoods, getgoodsBanner } from '../../api/home'
const state = {
  hotGoodses: [],
  newGoodses: [],
  recommendGoodses: [],
  goodsBanner: []
}

const mutations = {
  gethotGoodses(state, value) {
    state.hotGoodses = value
  },
  getnewGoodses(state, value) {
    state.newGoodses = value
  },
  getrecommendGoodses(state, value) {
    state.recommendGoodses = value
  },
  getgoodsBanner(state, value) {
    state.goodsBanner = value
  }
}

const actions = {
  async ReqhotGoodses(context) {
    const res = await getGoods()
    context.commit('gethotGoodses', res.data.hotGoodses)
  },
  async ReqnewGoodses(context) {
    const res = await getGoods()
    context.commit('getnewGoodses', res.data.newGoodses)
  },
  async ReqrecommendGoodses(context) {
    const res = await getGoods()
    context.commit('getrecommendGoodses', res.data.recommendGoodses)
  },
  async ReqgetgoodsBanner(context) {
    const res = await getgoodsBanner()
    context.commit('getgoodsBanner', res.data)
  }
}

const getters = {

}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}